import java.util.HashMap;
import java.util.Iterator;



public class FoundFiles {
	boolean debug = false;
	public HashMap<String, FileObject> files = new HashMap<String, FileObject>();
	
	public FoundFiles(){}
	
	public void addFile(String sha, FileObject file){
		if(!files.containsKey(sha))
			files.put(sha, file);
		
	}
	
	public String searchFileByName(String file){
		Iterator<String> iter = files.keySet().iterator();
		while(iter.hasNext()){
			String sha = (String)iter.next();
			if(debug) System.out.println("@searchFileByName - File in HashMap: " + files.get(sha).filename);
			if(file.equals(files.get(sha).filename))
				return sha;
		}
		return null;
	}
	
	public FileObject searchFileBySha(String sha)
	{
		Iterator<String> iter = files.keySet().iterator();
		while(iter.hasNext())
		{
			String shaValue = (String)iter.next();
			if(shaValue.equals(sha))
				return files.get(shaValue);
		}
		return null;
	}
	
}
